using System.ComponentModel;
using System.Drawing;
using System.Globalization;
using System.Windows.Forms;

namespace ICSharpCode.TextEditor.UserControls
{
	public class GotoForm : Form
	{
		private int _firstLineNumber;

		private int _lastLineNumber;

		private IContainer components = null;

		private Label lblLineNumber;

		private Button btnOk;

		private Button btnCancel;

		private Int32TextBox txtLineNumber;
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
        public int FirstLineNumber
		{
			get
			{
				return this._firstLineNumber;
			}
			set
			{
				this._firstLineNumber = value;
				this.UpdateLineNumberLabel();
			}
		}
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
        public int LastLineNumber
		{
			get
			{
				return this._lastLineNumber;
			}
			set
			{
				this._lastLineNumber = value;
				this.UpdateLineNumberLabel();
			}
		}
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
        public int SelectedLineNumber
		{
			get
			{
				if (!string.IsNullOrEmpty(this.txtLineNumber.Text) && int.TryParse(this.txtLineNumber.Text, out var result))
				{
					return result;
				}
				return 0;
			}
			set
			{
				this.txtLineNumber.Text = value.ToString(CultureInfo.InvariantCulture);
			}
		}

		public GotoForm()
		{
			this.InitializeComponent();
		}

		public DialogResult ShowDialogEx()
		{
			this.txtLineNumber.Min = this._firstLineNumber;
			this.txtLineNumber.Max = this._lastLineNumber;
			return base.ShowDialog();
		}

		private void UpdateLineNumberLabel()
		{
			this.lblLineNumber.Text = $"Line number ({this._firstLineNumber} - {this._lastLineNumber}):";
		}

		protected override void Dispose(bool disposing)
		{
			if (disposing && this.components != null)
			{
				this.components.Dispose();
			}
			base.Dispose(disposing);
		}

		private void InitializeComponent()
		{
			System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ICSharpCode.TextEditor.UserControls.GotoForm));
			this.lblLineNumber = new System.Windows.Forms.Label();
			this.btnOk = new System.Windows.Forms.Button();
			this.btnCancel = new System.Windows.Forms.Button();
			this.txtLineNumber = new ICSharpCode.TextEditor.UserControls.Int32TextBox();
			base.SuspendLayout();
			this.lblLineNumber.AutoSize = true;
			this.lblLineNumber.Location = new System.Drawing.Point(16, 13);
			this.lblLineNumber.Name = "lblLineNumber";
			this.lblLineNumber.Size = new System.Drawing.Size(95, 12);
			this.lblLineNumber.TabIndex = 0;
			this.lblLineNumber.Text = "行号 (1 - 999):";
			this.btnOk.DialogResult = System.Windows.Forms.DialogResult.OK;
			this.btnOk.Location = new System.Drawing.Point(114, 52);
			this.btnOk.Name = "btnOk";
			this.btnOk.Size = new System.Drawing.Size(75, 21);
			this.btnOk.TabIndex = 2;
			this.btnOk.Text = "确认";
			this.btnOk.UseVisualStyleBackColor = true;
			this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
			this.btnCancel.Location = new System.Drawing.Point(195, 52);
			this.btnCancel.Name = "btnCancel";
			this.btnCancel.Size = new System.Drawing.Size(75, 21);
			this.btnCancel.TabIndex = 3;
			this.btnCancel.Text = "取消";
			this.btnCancel.UseVisualStyleBackColor = true;
			this.txtLineNumber.Location = new System.Drawing.Point(16, 28);
			this.txtLineNumber.Max = int.MaxValue;
			this.txtLineNumber.Min = 1;
			this.txtLineNumber.Name = "txtLineNumber";
			this.txtLineNumber.Size = new System.Drawing.Size(254, 21);
			this.txtLineNumber.TabIndex = 1;
			this.txtLineNumber.Text = "1";
			base.AcceptButton = this.btnOk;
			base.AutoScaleDimensions = new System.Drawing.SizeF(6f, 12f);
			base.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
			base.CancelButton = this.btnCancel;
			base.ClientSize = new System.Drawing.Size(282, 80);
			base.Controls.Add(this.btnCancel);
			base.Controls.Add(this.btnOk);
			base.Controls.Add(this.txtLineNumber);
			base.Controls.Add(this.lblLineNumber);
			base.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
			base.Icon = (System.Drawing.Icon)resources.GetObject("$this.Icon");
			base.MaximizeBox = false;
			base.MinimizeBox = false;
			base.Name = "GotoForm";
			base.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
			this.Text = "转到行";
			base.ResumeLayout(false);
			base.PerformLayout();
		}
	}
}
